# -*- coding: utf-8 -*-
from flask import Flask, request, make_response, render_template
import json

app = Flask(__name__)

testInfo = {}


@app.route('/test_post', methods=['GET', 'POST'])
def test_post():
    print('received: ip:{} text:{}'.format(request.values['ip'],request.values['text']))
    testInfo['name'] = 'xiaoming'
    testInfo['age'] = '28'
    return json.dumps(testInfo)


@app.route('/')
def hello_world():
    return 'Hello World!'


@app.route('/js_flask')
def index():
    return render_template('js_flask.html')


if __name__ == '__main__':
    app.run(host='0.0.0.0',
            port=5000,
            debug=True
            )


# NOTE: ref site: https://www.jb51.net/article/144819.htm